<%@ page language="java" contentType= "text/html" pageEncoding="UTF-8"%>
<%@ page import="com.jm.web.form.TableToolbar" %>
<%@ page import="java.io.File" %>
<%@include file="/include/common/griduihead1.jsp"%>
<%
	//page1.setDebug(true);	
	page1.setSupportExtJs(false);
%>
<%@include file="/include/common/griduihead2.jsp"%>
<%
	page1.getPageTitle().setTitle("請假單查詢");
	
	Map newOption = new LinkedHashMap();
	newOption.put("新增(人資)", "rz");
		
	Map searchOption = new LinkedHashMap();
	searchOption.put("查询","{id:'search1',value:'',disabled:'false'}");
	searchOption.put("列出須審核資料","xs");
	
	TableToolbar tabar1 = page1.getTableToolbars("grid1");
%>
<jm:form>
	<jm:layout postion="north" >
		<jm:toolbar newDisabled="true" newOption="<%=newOption%>" searchOption="<%=searchOption%>" />
		<jm:pageTitle />
		<jm:sp id="sp1" data="<%=Utils.TAG_FORM%>" tabSize="2" >
			<jm:tab colModel="200px;200px;*">
				<jm:group colspan="3" caption="隱藏欄位" hidden="true">
					<input caption="hr021tsn" name="tsn" type="text" />	
					<input caption="xs" name="xs" type="text" />
				</jm:group>
				
				<jm:org caption="部門" name="org" lock="1,2,3" />
				<input caption="請假者工號" name="hrnum1" type="text" rule="custom:v_hrnum1" />
				<input caption="中英文姓名%" name="cename" type="text" />
				
				<input caption="審核者工號 " type="text" name="checkHrnum" />
				<jm:select caption="假别" name="hr013tsn" utils="<%=utils%>" dataSource="info3" sql="select tsn,leavekind from hr..hr013" />
				<jm:group colModel="200;*" captionDisplay="false">
					<jm:calendar name="sdate" caption="填寫日期" calConfig="onpicked:function(){$dp.$('edate').focus();}"/>
        			<jm:calendar name="edate" caption="~" captionWidth="10px"/>
				</jm:group>
                
                <jm:select caption="計酬方式" name="jobCode" codeList="計件工人;計件幹部;計時工人;計時幹部" />
                <input caption="列出未簽核 " type="checkbox" name="qh" value="1" />
                <jm:group colModel="200;*" captionDisplay="false">
        			<jm:calendar name="qsdate" caption="請假日期" calConfig="onpicked:function(){$dp.$('qedate').focus();}"/>
        			<jm:calendar name="qedate" caption="~" captionWidth="10px"/>
                </jm:group>
                
                <jm:multiselect colspan="3" width="400px" caption="PO" name="po1" type="textarea" config="valueconfig:{format:'%1$s/%2$s/%3$s',params:'ord_no,text,value'},cols:[{id:'ord_no',caption:'工序'},{id:'ord_no',hidden:true},{id:'text',hidden:true},{id:'value',hidden:true}]" dataSource="info6" utils="<%=utils%>" sql="select a.srn as po_srn,a.srn1 as mno_po_srn,a.ord_no,a.qty from js_ord..mno_po a join js_ord..dy_ltui b on a.srn= b.srn join js_ord..pre_dy_ltui c on b.agt_no = c.agt_no and b.cust_no = c.cus_no and b.yr = c.yr and b.season = c.season and b.style_cus = c.style_cus where c.srn = '8541'"/>
                
                <jm:multiselect colspan="3" width="400px" caption="PO" name="po2"  config="valueconfig:{format:'%1$s/%2$s/%3$s',params:'ord_no,text,value'},cols:[{id:'ord_no',caption:'工序'},{id:'ord_no',hidden:true},{id:'text',hidden:true},{id:'value',hidden:true}]" dataSource="info6" utils="<%=utils%>" sql="select a.srn as po_srn,a.srn1 as mno_po_srn,a.ord_no,a.qty from js_ord..mno_po a join js_ord..dy_ltui b on a.srn= b.srn join js_ord..pre_dy_ltui c on b.agt_no = c.agt_no and b.cust_no = c.cus_no and b.yr = c.yr and b.season = c.season and b.style_cus = c.style_cus where c.srn = '8541'"/>
                
                <jm:multiselect colspan="3" width="400px" caption="部門" name="dept"  type="table" config="loop:3,columncnt:2,textconfig:{format:'%1$s||%2$s',params:'text,value'},group:'parttsn',epnode:'',split:'/',cols:[{id:'value',hidden:true},{id:'text',caption:'部門'},{id:'parttsn',hidden:true}]" dataSource="info" utils="<%=utils%>" sql="select hr003tsn_mx,chfullname_mx,case parttsn when 1 then '電腦機' when 2 then '工廠' else '業務' end as parttsn from ps..psmx where parttsn<>0 union  select hr003tsn_mx,chfullname_mx,case parttsn when 1 then '電腦機' when 2 then '工廠' else '業務' end as parttsn from ps..psmx_1 order by parttsn"/>
                
                <jm:multiselect colspan="3" caption="生產範圍" name="sc"  config="valueconfig:{format:'%1$s/%2$s',params:'text,value'},cols:[{id:'value',caption:'工序號'},{id:'text',caption:'工序'}]" dataSource="info5" utils="<%=utils%>" sql="select gx_no,gx from prod..pd_wfgxno where LEN(gx_no)=2"/>
                
                <jm:combobox name="e_emailname" trigger="all" config="acwidht:200" utils="<%=utils%>" dataSource="info" sql="select emailname,emailadd from jmyarn..vdr_email" />
			</jm:tab>
			<jm:tab colModel="20%;20%;60%">	
				<input caption="工號2" name="hrnum14" type="text"  value="" />
				<select caption="測試4" name="hrnum15"><option value="1">1</option><option value="2">2</option><option value="3">3</option></select>
			</jm:tab>
		</jm:sp>
		<jm:error></jm:error>
	</jm:layout>
	<jm:layout postion="center" export="true">
		<span>testestrsefdsfsdfsdfdsf</span>
		<jm:export jxl="true" sheetname="請假單" exportConfig="x:1,y:1">
		<jm:table id="grid1" exportConfig="border:'all thin black'" view="fixedRow" toolbar="true" dataSet="<%=ret.getSerchResult()%>">
			<jm:thead >
					<tr exportConfig="bgcolor:'ocean_blue'">	
						<td rowspan="2">工號</td>
						<td colspan="12">明细</td>
					</tr>
					<tr exportConfig="bgcolor:'ocean_blue'">	
						<td>簽核</td>
						<td width="40px">姓名</td>
						<td width="10%">公司別</td>
						<td width="10%">部門</td>
						<td width="5%">類別</td>
						<td width="15%"><jm:html>請假時間</jm:html></td>
						<td width="5%" exportConfig="type:'number'">天數</td>
						<td width="10%">簽核情況</td>
						<td width="5%" exportConfig="type:'date'">填寫日期</td>
						<td width="5%">國別區域</td>
						<td width="15%">請假說明</td>
						<td width="5%">列印</td>
					</tr>
			</jm:thead>
			<jm:tbody>
				<%
				BaseDataEntity row = (BaseDataEntity)ret.getTableRow();
				boolean bEnab = "1".equals(row.gpsv("enab"));
				%>
				<tr bgcolor="<%=row.gpsv("bgcolor")%>">
					<td> <%
							if(bEnab && !row.isNullOrEmpty("editPage")){
								%><a href="<%=row.gpsv("editPage")%>" title="點擊工號進入編輯畫面"><%=row.gpsv("hrnum1")%></a><%
							}else{
								%><%=row.gpsv("hrnum1")%><%
							}
					%></td>
					<td><%
							if(bEnab && !row.isNullOrEmpty("checkPage")){
								%><a href="<%=row.gpsv("checkPage")%>" title="點擊工號進入簽核畫面"><font color="#FF0000"><b>簽核</b></font></a><%
							}else{
								%>&nbsp;<%
							}
					%></td>
					<td exportconfig="font-color:'pink'" ><%=row.gpsv("cName")%></td>
					<td><%=row.gpsv("companyNameCh")%></td>
					<td><%=row.gpsv("ChFullName")%></td>
					<td><%
						if(bEnab){
							%><a target="blank" href="/jmPro/staff/staff042E.jsp?tsn=<%=row.gpsv("tsn")%>&HRNum1=<%=row.gpsv("hrNum1")%>" title="點擊請假類別進入工作交接單畫面"><%=row.gpsv("leaveKind")%></a><%
						}else{
							%><%=row.gpsv("leaveKind")%><%
						}
					%></td>
					<td><%=row.gpsv("startDay")%>~<br><%=row.gpsv("endDay")%></td>
					<td exportconfig="font-color:'<%=row.gpiv("days") >= 1 ? "red" : "black"%>'"><%=row.gpsv("days")%></td>
					<td><%=bEnab ? row.gpsv("status"):"已取消"%></td>
					<td><%
							if(bEnab && !row.isNullOrEmpty("RzCheckPage")){
								%><a target="blank"  href="<%=row.gpsv("RzCheckPage")%>" title="人資部點此進入修改畫面"><font color="#FF0000"><b><%=row.GetFormatDate("crtDay")%></b></font></a><%
							}else{
								%><%=row.GetFormatDate("crtDay")%><%
							}
					%></td>
					<td><%=row.gpsv("AddrCty")%></td>
					<td exportconfig="wrap:'true'"><%=row.gpsv("rem")%></td>
					<td><%
						if(bEnab){
							%><a target="blank" href="/jmPro/staff/staff045Q.jsp?tsn=<%=row.gpsv("tsn")%>&HRNum1=<%=row.gpsv("hrNum1")%>" title="點擊此進入列印畫面"><u>列印</u></a><%
						}else{
							%>列印<%
						}
					%></td>
				</tr>
			</jm:tbody>
			<jm:tfoot>
				<tr>
					<td colspan="13">总计信息</td>
				</tr>
			</jm:tfoot>
		</jm:table>
		</jm:export>
	</jm:layout>
	<jm:layout postion="south" >test</jm:layout>
</jm:form>
<jm:script><script type="text/javascript" charset="UTF-8">
	//以下定义 action function ,on+action 命名function
	//new action
	function onnew(actionvalue){
		var url = '';
		switch (actionvalue) {
			case 'rz'://批量請假
				url = '/jmPro/staff/staff136E.jsp';break;
			default://普通假單
				$P.openwin('http://www.google.com','new','','',0,0);break;
		}
		if(url != '')
			window.location.href = url;
		return false;
	}
	
	//工号验证
	function v_hrnum1(_me){
		if($(_me).val() == '')return true ;
		var rs = {ret:0,msg:"無此工號!"},p = {};
		var p ={};
		p['action'] = "v_hrnum1";
		p['hrnum'] = $('input[name=hrnum]').val();
		
		var doaction = function(jo){
			 if(jo != undefined && jo.ret == 1)
				 rs.ret = 1;
		};
		
		$P.ajax({data : p,succ :doaction});
		return rs;
	}
</script></jm:script>
<%@include file="/include/common/griduiend.jsp"%>
<%
	if(page1.isExport() && page1.getExportAction().getFileName() != null){
		Mail mail = new Mail();
		mail.setTo("yanjie@mail.jmknit.com");
		mail.setSubject("郵件測試!");
		mail.setFileName("test.xls");
		mail.setFile(new File(page1.getExportAction().getFileName().toString()));
		utils.sendMail(mail);
	}
%>